﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace Gin.Controls
{
    public class UserInputTextBox : UserInputControl
    {
        private const string DATA_TAG = "DataControl";
        private const int TOTAL_CONTROL_HEIGHT = 50;
        private const int SUBCONTROL_PADDING = 5;
        private const int TEXTBOX_TOP = 20;

        public string Caption { get; set; }
        public string InitialValue { get; set; }

        public override Control Create(int containerWidth)
        {
            Height = TOTAL_CONTROL_HEIGHT;

            Panel control = new Panel();

            Label caption = new Label();
            caption.AutoSize = true;
            caption.Text = Caption;
            caption.Top = SUBCONTROL_PADDING;
            caption.Left = SUBCONTROL_PADDING;
            control.Controls.Add(caption);

            TextBox textbox = new TextBox();
            textbox.Text = InitialValue;
            textbox.Left = SUBCONTROL_PADDING;
            textbox.Top = TEXTBOX_TOP;
            textbox.Tag = DATA_TAG;
            control.Controls.Add(textbox);

            return control;
        }

        public override object ReadValue(Control control)
        {
            return ReadTextBoxDefault(control, DATA_TAG);
        }
    }
}
